package org.example.spring.context;

import org.example.spring.factory.MyBeanFactory;
import org.example.spring.factory.MyDefaultListableBeanFactory;

public class MyGeneralApplicationContext implements MyApplicationContext {
    // 持有myBeanFactory的引用
    private MyBeanFactory myBeanFactory;

    public MyGeneralApplicationContext() {
        // 创建beanfactory
        this.myBeanFactory = new MyDefaultListableBeanFactory();
    }

    // 从容器中获取对象
    public <T> T getBean(String beanName, Class<T> beanClassType) {
        return this.myBeanFactory.registerBeanDefinition(beanName, beanClassType);
    }

    public MyBeanFactory getMyBeanFactory() {
        return this.myBeanFactory;
    }
}
